<!DOCTYPE html>
<html lang="zh-CN">

<head>
	{include file="public/header" /}
	<title>秒到3.0商户管理后台-添加商品</title>

	<link href="/public__STATIC__/admin/layui/css/layui.css?v={:date('ymd')}" rel="stylesheet" type="text/css" />
	<link href="/public__STATIC__/admin/layui/css/modules/code.css" rel="stylesheet" type="text/css" />
	<script src="/public__STATIC__/admin//select2.full.js" type="text/javascript"></script>
	<link href="/public__STATIC__/admin/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
	<link href="/public__STATIC__/admin/css/admin_style.css" rel="stylesheet" type="text/css" />
</head>
<body class="page-header-fixed page-sidebar-closed-hide-logo page-content-white">
<div class="page-wrapper">
	{include file="public/navbar" /}//
	<div class="clearfix"></div>
	<div class="page-container">
		{include file="public/sidebar" /}
		<div class="page-content-wrapper">
			<div class="page-content">
				<div class="row bordered">
					<div class="col-md-9">
						<div class="portlet light  relative">
							<div class="portlet-title">
								<div class="caption">
									<i class="icon-settings font-dark"></i><span class="caption-subject bold uppercase">配送设置</span></br>
									<span class="form-control-static pull-left zhushi margin-right">设置订单商品的配送方式和运费，并根据买家增加商品而追加运费</span>
								</div>
								<div class="actions">
									<div class="btn-group"></div>
								</div>
							</div>
							<div class="portlet-body">
								<div class="box-content col-md-8  table-bordered table">
													<span class="form-control-static  margin-right">
														<img class="margin-right" src="/public__STATIC__/admin/image/u5339.png">
													</span>
										<span class="form-control-static zhushi margin-right">
											<span style="font-size: 18px">
											物流配送</span>
											</br>
											由第三方快递公司或商家完成商品配送服务
										</span>
								</div>
							<from>
								<div class="portlet light  relative">
									<div class="form-group">
										<label class="col-lg-2 col-xs-4 control-label"> <span class="required"> * </span>是否启用：</label>
										<div class=" col-lg-4 col-xs-3">
											<div class="relative">
												<label class="radio-inline">
													<input class="is_enable" type="radio" name="is_enable" value="1" checked/>
													是
												</label>
												<label class="radio-inline">
													<input class="is_enable" type="radio" name="is_enable"  value="2" />
													否</label>
											</div>
										</div>
									</div>
								</div>
								<div class="portlet light  relative">
									<div class="form-group">
										<label class="col-lg-2 col-xs-4 control-label"> <span class="required">   * </span>配送费用：</label>
										<div class=" col-md-10 form-inline">
											<span class="  ">订单起送价</span>
											<input class="orderStartingPrice  form-control margin-left" type="text" name="orderStartingPrice"/>
											<span>元</span>
											<span class="  ">运费</span><input class="orderStartingPrice  form-control margin-left" type="text" name="freight"/><span>元</span>
											<span class="  ">打包费用</span><input class="orderStartingPrice  form-control margin-left" type="text" name="packingCharge"/><span>元</span>
										</div>
									</div>
								</div>
								<div class="portlet light  relative">
									<div class="form-group">
										<label class="col-lg-2 col-xs-4 control-label"> <span class="required">   * </span> 距离加价：</label>
										<div class=" col-md-10 form-inline">
											<span class="col-md-3">0kg ＜ 商品重量 ≤ 5kg</span><span class="">加价</span>
											<input class="orderStartingPrice  form-control margin-left" type="text" name="distanceIncrease_0_5"/>
											<span>元</span>
										</div>
									</div>
								</div>
								<div class="portlet light  relative">
									<div class="form-group">
										<label class="col-lg-2 col-xs-4 control-label"> </label>
										<div class=" col-md-10 form-inline">
											<span class="col-md-3">2kg ＜ 商品重量 ≤ 10kg</span><span class="">每增1kg加价</span>
											<input class="orderStartingPrice  form-control margin-left" type="text" name="distanceIncrease_2_10"/>
											<span>元</span>
										</div>
									</div>
								</div>
								<div class="portlet light  relative">
									<div class="form-group">
										<label class="col-lg-2 col-xs-4 control-label"> </label>
										<div class=" col-md-10 form-inline">
											<span class="col-md-3">10kg ＜ 商品重量 ≤ 50kg</span><span class="">每增5kg加价</span>
											<input class="orderStartingPrice  form-control margin-left" type="text" name="distanceIncrease_10_50"/>
											<span>元</span>
										</div>
									</div>
								</div>
								<div class="portlet light  relative">
									<div class="form-group">
										<label class="col-lg-2 col-xs-4 control-label"> <span class="required">   * </span>夜间加价：</label>
										<div class=" col-md-10 form-inline">
											<span class="  ">22:00 ~ 24:00</span>
											<span class="">加价</span>
											<input class="orderStartingPrice  form-control margin-left" type="text" name="nocturnalPriceIncrease_22_24"/>
											<span>元</span>
										</div>
									</div>
								</div>
								<div class="portlet light  relative">
									<div class="form-group">
										<label class="col-lg-2 col-xs-4 control-label"> </label>
										<div class=" col-md-10 form-inline">
											<span class="  ">00:00 ~ 07:00</span>
											<span class="">加价</span>
											<input class="orderStartingPrice  form-control margin-left" type="text" name="nocturnalPriceIncrease_00_07"/>
											<span>元</span>
										</div>
									</div>
								</div>
								<div class="portlet light  relative div_relative">
									<div class="form-group">
										<label class="col-lg-2 col-xs-4 control-label"> </label>
										<div class=" col-md-10 form-inline">
											<input type="button" class="btn btn-default  box_relative" value="取消">
											<input id="" class="btn btn-default margin-right box_relative " type="submit" value="保存">
										</div>
									</div>
								</div>
							</from>
							</div>
					</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="page-footer">
		<div class="page-footer-inner">
			2017 &copy; 秒迅科技</a>
		</div>
		<div class="scroll-to-top">
			<i class="icon-arrow-up"></i>
		</div>
	</div>
</div>
</body>
</html>

<script>
	$(function(){

		//is_enable ,                     //是否启用
		// orderStartingPrice,           //订单起送价格
		//freight						 //物流
		// packingCharge,                //打包费
		// distanceIncrease_0_5,        //距离加价0kg-5kg
		// distanceIncrease_2_10,       //距离加价2kg-10kg
		// distanceIncrease_10_50,      //距离加价10kg-50kg
		// nocturnalPriceIncrease_22_24,  //夜间加价22:00-24:00
		// nocturnalPriceIncrease_00_07   //夜间加价00:00-07:00

		var is_enable = $('.is_enable').val();
		var orderStartingPrice = $('#orderStartingPrice').val();
		var freight = $('#freight').val();
		var packingCharge = $('#packingCharge').val();
		var distanceIncrease_0_5 = $('#distanceIncrease_0_5').val();
		var distanceIncrease_2_10 = $('#distanceIncrease_2_10').val();
		var distanceIncrease_10_50 = $('#distanceIncrease_10_50').val();
		var nocturnalPriceIncrease_22_24 = $('#nocturnalPriceIncrease_22_24').val();
		var nocturnalPriceIncrease_00_07 = $('#nocturnalPriceIncrease_00_07').val();

		var params = {
			is_enable:is_enable,
			orderStartingPrice:orderStartingPrice,
			freight:freight,
			packingCharge:packingCharge,
			dI_0_5:distanceIncrease_0_5,
			dI_2_10:distanceIncrease_2_10,
			dI_10_50:distanceIncrease_10_50,
			nP_22_24:nocturnalPriceIncrease_22_24,
			nPI_00_07:nocturnalPriceIncrease_00_07
		};

		$(".is_enable").click(function(){
			$(".is_enable").removeAttr("checked");
			$(this).attr("checked",true);
			$(this).prop("checked",true);
		});

		var $tenantArr = [];
		var valStr = "";

		$("#tenant").change(function(){
			var $tenantObj = {};
			var flag = true;
			var $_thisval = $("#tenant").val();
			$(this).find("option[value!="+$_thisval+"]").attr("selected",false);
			$("#tenant").find("option[value="+$_thisval+"]").attr("selected",true);
			var $_thistext = $("#tenant").find("option[value="+$_thisval+"]").text();

			$tenantObj.value=$_thisval;
			$tenantObj.text=$_thistext;
			for(var i = 0;i<$tenantArr.length;i++){
				if($tenantArr[i].value == $_thisval){
					flag = false;
				}
			}
			if(flag){
				$tenantArr.push($tenantObj);
				var html = '<div class="table-bordered  text-muted  col-lg-3 col-xs-2" style="margin-left: 20px">'+
						$_thistext+
						'<i class="layui-icon  layui-col-md-offset3 store-class" store-id ="'+$_thisval+'">'+'&#x1006'+'</i>'
				'</div>'
				$(".tenant_select_val").append(html);
				console.log($tenantArr)
			}
			valStr = JSON.stringify($tenantArr)

			//test
			$(".tenant_select_val").find('.store-class').click(function(){
				var storeId = $(this).attr('store-id');
				var reindex = "";

				$.each($tenantArr,function(index,el){
					if(el.value == storeId){
						reindex = index;
						console.log(reindex)
					}
				});

				$tenantArr.remove($tenantArr[reindex])
				console.log($tenantArr)
				$(this).parent().remove();
			});
		});

		/**
		 *删除数组指定下标或指定对象
		 */
		Array.prototype.indexOf = function(val) {
			for (var i = 0; i < this.length; i++) {
				if (this[i] == val) return i;
			}
			return -1;
		};

		Array.prototype.remove = function(val) {
			var index = this.indexOf(val);
			if (index > -1) {
				this.splice(index, 1);
			}
		};

	})
</script>